﻿using System.Collections.Generic;
using Algoritmia.DataStructures.Maps;

namespace Algoritmia.DataStructures.PriorityMaps
{
    public interface IPriorityMap<TKey,TValue> : IMap<TKey,TValue>
    {
        KeyValuePair<TKey, TValue> GetOptimal();
        KeyValuePair<TKey, TValue> ExtractOptimal();
    }

    public static class PriorityMapsExtensions
    {
        public static TKey GetOptimalKey<TKey, TValue>(this IPriorityMap<TKey, TValue> priorityMap)
        {
            return priorityMap.GetOptimal().Key;
        }

        public static TValue GetOptimalValue<TKey,TValue> (this IPriorityMap<TKey,TValue> priorityMap)
        {
            return priorityMap.GetOptimal().Value;
        }

        public static TKey ExtractOptimalKey<TKey, TValue>(this IPriorityMap<TKey, TValue> priorityMap)
        {
            return priorityMap.ExtractOptimal().Key;
        }

        public static TValue ExtractOptimalValue<TKey, TValue>(this IPriorityMap<TKey, TValue> priorityMap)
        {
            return priorityMap.ExtractOptimal().Value;
        }
    }
}
